"""
动态信息，如图的使用时间等
"""
from flask import Blueprint, request, jsonify
import server.database.sql.activity.activity as db
import server.web.controllers.common as common


route_activity = Blueprint('activity', __name__)


# 按条件获取gids
# 默认
@route_activity.route('/all', methods=['GET'])
def get_activity_all():
    if request.method == 'GET':
        uid = request.args.get('uid')
        page_size = request.args.get('page_size')
        page = request.args.get('page')
        order = request.args.get('order')
        order_by = request.args.get('order_by')
        # 获取gids
        res = db.get_activity_all(uid, page_size, page, order, order_by)
        tol_num = res['tol_num']
        data = res['data']
        # gids = [list(d.values())[0] for d in data]
        res = common.get_describes_by_gids(data)

        return jsonify({'data': res, 'tol_num': tol_num})

